<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/alllayui/layui/css/layui.css}" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<div class="searchTable">
    房间号：
    <div class="layui-inline">
        <input class="layui-input" name="rno" id="rno" autocomplete="off">
    </div>
    <button id="searchBtn" class="layui-btn" data-type="reload">搜索</button>
</div>
<table class="layui-hide" id="Room" lay-filter="Room"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <!--<shiro:hasPermission name="room/add">
            <button class="layui-btn layui-btn-sm" lay-event="add">新增</button>
        </shiro:hasPermission>-->
    </div>
</script>

<script type="text/html" id="barDemo">
    <shiro:hasPermission name="room/update">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    </shiro:hasPermission>
    <shiro:hasPermission name="room/delete">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </shiro:hasPermission>
</script>


<script th:src="@{/alllayui/layui/layui.js}" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use(['jquery', 'table'], function () {
        var table = layui.table;

        table.render({
            elem: '#Room'
            , url: '/roomlog/list'
            , method: 'post'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , title: 'Room'
            , cols: [
                [
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'logid', title: '日志id', align: 'center'}
                    , {field: 'rno', title: '房间号', align: 'center'}
                    , {field: 'oldcost', title: '原费用', align: 'center'}
                    , {field: 'newcost', title: '修改后费用', align: 'center'}
                    , {field: 'updatetime', title: '修改时间', align: 'center', templet: "<div>{{layui.util.toDateString(d.sbj_start, 'yyyy年-MM月-dd日 HH:mm:ss')}}</div>"}
                ]
            ]
            , page: true
            , request: {
                pageName: 'currentPageNum' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": res.totalRecords, //解析数据长度
                    "data": res.recordList //解析数据列表
                };
            }

        });


        var $ = layui.$, active = {
            reload: function () {
                var rno$_ = $('#rno');

                var queryWhere = {};
                queryWhere['rno'] = rno$_.val();

                //执行重载
                table.reload('Room', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: queryWhere
                }, 'data');
            }
        };

        $('.searchTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });


</script>

</body>
</html>